gtkmenusectionbox: remove submenus when the parent item is removed
authorJonathan Matthew <jonathan@d14n.org>
Wed, 9 Mar 2016 12:44:45 +0000 (22:44 +1000)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 20 Apr 2016 21:28:19 +0000 (17:28 -0400)
https://bugzilla.gnome.org/show_bug.cgi?id=749405

gtk/gtkmenusectionbox.c

index 2de27dab0b5ac5465d282c2525c8c6963e7b43ff..455637d6e5e0c1b605d90bfa4469f79e196b17fa 100644 (file)
@@ -195,9 +195,25 @@ gtk_menu_section_box_remove_func (gint     position,
                                   gpointer user_data)
 {
   GtkMenuSectionBox *box = user_data;
+  GtkMenuTrackerItem *item;
+  GtkWidget *widget;
   GList *children;
 
   children = gtk_container_get_children (GTK_CONTAINER (box->item_box));
+
+  widget = g_list_nth_data (children, position);
+
+  item = g_object_get_data (G_OBJECT (widget), "GtkMenuTrackerItem");
+  if (gtk_menu_tracker_item_get_has_link (item, G_MENU_LINK_SUBMENU)) {
+    GtkWidget *stack, *subbox;
+
+    stack = gtk_widget_get_ancestor (GTK_WIDGET (box->toplevel), GTK_TYPE_STACK);
+    subbox = gtk_stack_get_child_by_name (GTK_STACK (stack), gtk_menu_tracker_item_get_label (item));
+    if (subbox != NULL) {
+      gtk_container_remove (GTK_CONTAINER (stack), subbox);
+    }
+  }
+
   gtk_widget_destroy (g_list_nth_data (children, position));
   g_list_free (children);